import { request } from '@/utils/request'
import type {
  ResponseResult,
  PageResponse,
  BaseSearchParams,
  ListFormModel,
  ProjectFormModel,
  PlanFormModel,
  LevelFormModel,
  StatusParams
} from '@/api/model/serveModel'

//-------------------------------------------------- 护理项目----------------------------------------
//1.查询所有
export function getAllProjectList() {
  return request.get<ResponseResult<ListFormModel<ProjectFormModel>>>({
    url: `/nursing/project/all`
  })
}
//2.分页查询
export function getProjectPage(params:BaseSearchParams) {
  return request.get<ResponseResult<PageResponse<ProjectFormModel>>>({
    url: `/nursing/project`,
    params
  })
}
//3.详情
export function getProjectDetails(id:number) {
  return request.get<ResponseResult<ProjectFormModel>>({
    url: `/nursing/project/${id}`
  })
}
//4.添加
export function addProject(data: ProjectFormModel) {
  return request.post<ResponseResult<String>>({
    url: '/nursing/project',
    data: data
  })
}
//4.修改
export function updateProject(data: ProjectFormModel) {
  return request.put<ResponseResult<String>>({
    url: '/nursing/project',
    data: data
  })
}
//5.删除
export function deleteProject(id:number) {
  return request.delete<ResponseResult<String>>({
    url: `/nursing/project/${id}`
  })
}
// 6.禁用启用
export function updateProjectStatus(params:StatusParams) {
  return request.put<ResponseResult<String>>({
    url: `/nursing/project/${params.id}/status/${params.status}`
  })
}


//-------------------------------------------------- 护理计划----------------------------------------
//1.查询所有
export function getAllPlanList() {
  return request.get<ResponseResult<ListFormModel<PlanFormModel>>>({
    url: '/nursing/plan/all'
  })
}
//2.分页查询
export function getPlanPage(params:BaseSearchParams) {
  return request.get<ResponseResult<PageResponse<PlanFormModel>>>({
    url: '/nursing/plan/search',
    params
  })
}
//3.查询详情
export function getPlanDetails(id:number) {
  return request.get<ResponseResult<PlanFormModel>>({
    url: `/nursing/plan/${id}`
  })
}
//4.添加
export function addPlan(data: PlanFormModel) {
  return request.post<ResponseResult<String>>({
    url: '/nursing/plan',
    data: data
  })
}
//5.修改
export function updatePlan(data:PlanFormModel) {
  return request.put<ResponseResult<String>>({
    url: `/nursing/plan/${data.id}`,
    data: data
  })
}
// 6.删除
export function deletePlan(id:number) {
  return request.delete<ResponseResult<String>>({
    url: `/nursing/plan/${id}`
  })
}
// 7.禁用启用
export function updatePlanStatus(params:StatusParams) {
  return request.put<ResponseResult<String>>({
    url: `/nursing/plan/${params.id}/status/${params.status}`
  })
}

//-------------------------------------------------- 护理等级----------------------------------------
//1.查询所有
export function getAllLevelList() {
  return request.get<ResponseResult<ListFormModel<LevelFormModel>>>({
    url: '/nursing/level/listAll'
  })
}
//2.分页查询
export function getLevelPage(params:BaseSearchParams) {
  return request.get<ResponseResult<PageResponse<LevelFormModel>>>({
    url: `/nursing/level/listByPage`,
    params
  })
}
//3.查询详情
export function getLevelDetails(id:number) {
  return request.get<ResponseResult<LevelFormModel>>({
    url: `/nursing/level/${id}`
  })
}
//4.添加
export function addLevel(data:LevelFormModel) {
  return request.post<ResponseResult<String>>({
    url: '/nursing/level/insert',
    data: data
  })
}
//5.修改
export function updateLevel(data:LevelFormModel) {
  return request.put<ResponseResult<String>>({
    url: `/nursing/level/update`,
    data: data
  })
}
//6.删除
export function deleteLevel(id:number) {
  return request.delete<ResponseResult<String>>({
    url: `/nursing/level/delete/${id}`
  })
}
//7.禁用启用
export function updateLevelStatus(params:StatusParams) {
  return request.put<ResponseResult<String>>({
    url: `/nursing/level/${params.id}/status/${params.status}`
  })
}


//------------------------------------------------护理任务-------------------------------------------------------------
//1.查询分页
export function getArrangeList(params) {
  return request.get({
    url: `/nursing/task/page`,
    params
  })
}
//2.执行护理任务
export function executePlan(params) {
  return request.put({
    url: `/nursing/task/do?estimatedServerTime=${params.estimatedServerTime}&mark=${params.mark}&taskId=${params.taskId}&taskImage=${params.taskImage}`
  })
}
//3.取消
export function cancelPlan(params) {
  return request.put({
    url: `/nursing/task/cancel?reason=${params.reason}&taskId=${params.taskId}`
  })
}
//4.修改执行日期
export function changePlanTime(params) {
  return request.put({
    url: `/nursing/task/updateTime?estimatedServerTime=${params.estimatedServerTime}&taskId=${params.taskId}`
  })
}
//5.查询详情
export function getTaskDetail(params) {
  return request.get({
    url: `/nursing/task`,
    params
  })
}
//6.修改给老人设置护理员
export function setNurseForOlder(params: any) {
  return request.put({
    url: `/elder/setNursing`,
    data: params
  })
}
